package com.qianfeng.wuyang.ximalaya.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.qianfeng.wuyang.ximalaya.R;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by ShenHao on 2016/12/2.
 */

public class Fragment_Classify extends Fragment implements Callback<Bean_ClassifyTop> {






    private List<Entity_Classify>list_data;
    private Classify_Adapter adapter;

    ListView listView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

       list_data=new ArrayList<>();
        return inflater.inflate(R.layout.fragment_calssify,container,false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        MyApplication application = (MyApplication) getActivity().getApplication();
        application.getService().getList("and-a1","android",13,2).enqueue(this);

        ListView listVIew= (ListView) view.findViewById(R.id.list_fragment_classify);

        adapter=new Classify_Adapter(list_data,getContext());
      listVIew.setAdapter(adapter);


    }


    @Override
    public void onResponse(Call<Bean_ClassifyTop> call, Response<Bean_ClassifyTop> response) {
        list_data.addAll(response.body().getList());

        for (int i = 0; i < list_data.size(); i++) {
        }
        adapter.notifyDataSetChanged();

    }

    @Override
    public void onFailure(Call<Bean_ClassifyTop> call, Throwable t) {

    }
}
